package com.mysteel.monitor.controller;

import com.mysteel.monitor.core.annotation.Monitor;
import com.mysteel.monitor.core.annotation.MonitorMethod;
import com.mysteel.monitor.core.response.RespResult;
import com.mysteel.monitor.core.utils.MapUtil;
import com.mysteel.monitor.core.utils.PidUtils;

import java.util.List;

/**
 * 堆栈信息
 * @author:admin
 */
@Monitor("/v1/api/dump")
public class DumpController {
    /**
     *  查询全部活跃的对象
     */
    private static  final  String LIVE_COMMAND = "live";
    @MonitorMethod("live")
    public RespResult<String> execCommand() throws Exception {
        String currentId = PidUtils.currentPid();
        List<String> lst = MapUtil.excute(LIVE_COMMAND,currentId);
         List<String> _per = lst.subList(0,103);
         // 添加最后一条
        _per.add(0,lst.get(lst.size() -1));
        return  RespResult.success(_per);
    }



}
